package ism.api{
	import com.adobe.kiwi.connections.IServiceFactory;
	import com.adobe.kiwi.feeds.atom.*;
	import com.adobe.kiwi.feeds.atom.v10.impl.Atom10FeedFactory;
	import com.adobe.net.URI;
	
	import mx.controls.Alert;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.HTTPService;

	public class UrlTest{
	
		function UrlTest() {
			trace("constructor called");
  			//useHttpService(null); 
  			
  			var serviceURI:URI = new URI("http://bitworking.org/projects/apptestsite/app.cgi/service/;service_document");
  			trace( serviceURI.authority);
  			trace( serviceURI.fragment);
  			trace( serviceURI.path);
  			trace( serviceURI.queryRaw);

  			trace( serviceURI.scheme);
  			trace( serviceURI.username);  			
  			trace( serviceURI.isRelative());
  			  			
  			trace( serviceURI.toString());
  			trace( serviceURI.getFilename(true));
  			  			  			
  			var feedFactory:IAtomFeedFactory = new Atom10FeedFactory();
			var feedElementFactory:IAtomFeedElementFactory = new Atom10FeedFactory();
			var serviceFactory:IServiceFactory = new AnyService();
			
  			var proto:AnyProtocol = new AnyProtocol(serviceURI, feedFactory, feedElementFactory, serviceFactory);
  			trace(proto);
  			proto.getService();
  			
  		}
  		  	
    public function useHttpService(parameters:Object):void {
        var service:HTTPService = new HTTPService();
       // service.destination = "http://bitworking.org/projects/apptestsite/app.cgi/service/;service_document";
        service.url = "http://bitworking.org/projects/apptestsite/app.cgi/service/;service_document";
        service.method = "GET";
        service.resultFormat="e4x";
        service.addEventListener("result", httpResult);
        service.addEventListener("fault", httpFault);
        service.send();
    }

    public function httpResult(event:ResultEvent):void {
        var result:Object = event.result;
		trace(result)
        //Do something with the result.
    }

    public function httpFault(event:FaultEvent):void {
        Alert.show("Boark" + event);
    }
  		
	}
}